package org.example.test;

import org.example.config.SpringConfig;
import org.example.entity.user;
import org.example.mapper.usermapper;
import org.example.service.userservice;
import org.example.service.userservices.userserviceimpl;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import java.util.List;

//使用 Spring 整合 Junit 专用的类加载器
@RunWith(SpringJUnit4ClassRunner.class)
//加载配置文件或者配置类
@ContextConfiguration(classes = {SpringConfig.class}) //加载配置类
//@ContextConfiguration(locations={"classpath:applicationContext.xml"})
// 加载配置文件
public class test1 {

    @Autowired
    userservice userservice;

    @Test
    public void selectbyid() {
        user user = userservice.selectById(2);
        System.out.println(user);

    }

    @Test
    public void selectall() {
        List<user> users = userservice.selectAll();
        users.forEach(System.out::println);
    }



}
